package cn.itcast.mq.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CommonConfig {
    // 序列化成json格式
    /*@Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }*/

    // 声明定向交换机simple.direct
    /*@Bean
    public DirectExchange simpleExchange() {
        return new DirectExchange("simple.direct", false, false);
    }   */

    // 交换机持久化 默认持久化
    /* @Bean
    public DirectExchange simpleExchange() {
        return new DirectExchange("simple.direct", true, false);
    }*/

    // 声明simple.queue队列
    /*@Bean
    public Queue simpleQueue() {
        return new Queue("simple.queue", false);
    }*/

    // 队列持久化 声明simple.queue队列 使用QueueBuilder构建队列，durable就是持久化的
    /*@Bean
    public Queue simpleQueue() {
        return QueueBuilder.durable("simple.queue").build();
    }*/

    // simple.queue 绑定到 交换机simple.direct  指定routingKey="simple"
    /*@Bean
    public Binding simpleBinding() {
        return BindingBuilder.bind(simpleQueue())
                .to(simpleExchange()).with("simple");
    }*/



}
